/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package core.factory;

import core.proxy.WorkerDiscoveryProxy;
import core.proxy.WorkerDiscoveryProxyP2P;
import core.util.COREServiceRegistry;
import org.apache.log4j.Logger;

/**
 * Classe Factory singleton che crea l'istanza del proxy del Discovery ed in particolare del Worker Discovery
 *
 * @author Scuderi Giovanni Luca, Vincenzo Merlo, Paolo Giuffrida
 */
public class DiscoveryProxyFactory {

    private final Logger logger = COREServiceRegistry.getLogger(DiscoveryProxyFactory.class.toString()); //istanza logger in log4j
    private volatile static DiscoveryProxyFactory instance = null; // variabile per il singleton 

    /*
     * Costruttore privato per singleton
     */
    private DiscoveryProxyFactory() {
        logger.trace("DiscoveryProxyFactory");
    }

    /**
     * Ritorna il proxy associato, in particolare ritorna una istanza di WorkerDiscoveryProxyP2P
     * @return istanza del proxy
     */
    public WorkerDiscoveryProxy getProxy() {        
        return new WorkerDiscoveryProxyP2P();
    }

    /**
     * Metodo singleton
     * @return istanza singleton
     */
    public static DiscoveryProxyFactory getInstance()
    {
        if(instance == null) instance = new DiscoveryProxyFactory();
        return instance;
    }

    /**
     * Metodo toString
     * @return stringa che rappresenta l'oggetto
     */
    @Override
    public String toString() {
    	return DiscoveryProxyFactory.class.getSimpleName();    	
    }
    
}
